﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace CCD
{
    public partial class AddModelDialog : Form
    {
        public AddModelDialog()
        {
            InitializeComponent();
        }

        private void ModelNameConfirm_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length == 0)
                MessageBox.Show("Model name can't be empty!");
            else
            {
                ModelAndBlockManager father = (ModelAndBlockManager)this.Owner;
                if (father.AddModel(textBox1.Text))
                {
                    MessageBox.Show("Add model Successfully!");
                    this.Close();
                }
                else
                    MessageBox.Show("This name has already existed! Try another!");
            }
        }

        private void EnterForm(object sender, EventArgs e)
        {
            this.textBox1.Focus();
        }

        private void EnterPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
                ModelNameConfirm_Click(sender, e);
        }
    }
}
